unit UPessoaControl;

interface

uses UIMVCinterfaces, UPessoaModel, Dialogs;

type
  IControlPessoa = interface(IControl)
    ['{16C0ECF6-A777-46ED-BB27-80ADD7008851}']
    procedure SearchName(const Value: String);
    procedure Insert;
    procedure Delete;
    procedure Update;
    procedure Save;
    procedure Cancel;

    procedure Initialize;

    procedure SetModel(const Value: IManterContato);
    procedure SetView(const Value: IView);

    function GetModel: IManterContato;
    function GetView: IView;

    property Model: IManterContato read GetModel write SetModel;
    property View: IView read GetView write SetView;
    
  end;

  TPessoaControl = class(TInterfacedObject, IControlPessoa)
    private
      FModel: IManterContato;
      FView: IView;

      procedure SetModel(const Value: IManterContato);
      procedure SetView(const Value: IView);

      function GetModel: IManterContato;
      function GetView: IView;

    protected

    public
      procedure SearchName(const Value: String);
      procedure Insert;
      procedure Delete;
      procedure Update;
      procedure Save;
      procedure Cancel;
      procedure Initialize;

      property Model: IManterContato read GetModel write SetModel;
      property View: IView read GetView write SetView;

  end;

implementation

{ TPessoaControl }

procedure TPessoaControl.Cancel;
begin
  FModel.Cancel;
end;

procedure TPessoaControl.Delete;
begin
  FModel.Delete
end;

function TPessoaControl.GetModel: IManterContato;
begin
  Result := FModel;
end;

function TPessoaControl.GetView: IView;
begin
  Result := FView;
end;

procedure TPessoaControl.Initialize;
begin
  FModel.Initialize;
end;

procedure TPessoaControl.Insert;
begin
  FModel.Insert;
end;

procedure TPessoaControl.Save;
begin
  FModel.Save;
end;

procedure TPessoaControl.SearchName(const Value: String);
begin
  FModel.SearchName(Value);
end;

procedure TPessoaControl.SetModel(const Value: IManterContato);
begin
  FModel := Value;
end;

procedure TPessoaControl.SetView(const Value: IView);
begin
  FView := Value;
end;

procedure TPessoaControl.Update;
begin
  FModel.Update;
end;

end.
 